const {resolve} = require("path");
const HtmlWebpackPlugin = require('html-webpack-plugin');
const VueLoaderPlugin = require('vue-loader/lib/plugin');

module.exports = {
    mode:"production",
    entry:"./src/main.js",
    output:{
        filename:"js/bundle.js",
        path:resolve(__dirname,"dist")
    },
    module:{
        rules:[
            //vue
            {
                test:/\.vue$/,
                loader:"vue-loader"
            },
            //css
            {
                test:/\.css$/,
                use:["style-loader","css-loader"]
            },
            //less
            {
                test:/\.less$/,
                use:["style-loader","css-loader","less-loader"]
            },
            //js
            {
                test:/\.js$/,
                use:["babel-loader"]
            }
        ]
    },
    plugins:[
        new HtmlWebpackPlugin({
            template:"./src/index.html"
        }),
        new VueLoaderPlugin()
    ],
    devServer:{
        port:3000,
        hot:true,
        contentBase:resolve(__dirname,"dist"),
        open:true
    }
}